//index.js
//获取应用实例
const app = getApp()
const util = require('../../utils/util.js')

Page({
  data: {
    // motto: 'Hello World',
    // userInfo: {},
    // hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    statubar_height: 0,
    showProfile: 'none',
    liked: false,
    liked_img: '../img/favorite.png',
    showMsg: 'block',
    douyinUserNo: '',
    videoMsg: {},
  },

  onLoad: function (option) {
   console.log(123456)
    console.log(option)

    this.setData({
      statubar_height: app.globalData.statubar_height,
      douyinUserNo: option.userNo,
    })

    this.getVideoMsg()
  },

  //跳转个人主页
  showPro: function (e) {
      console.log('主页')
      console.log(e)
    wx.navigateTo({
        url: '../profile/profile?data=' + JSON.stringify({ 'douyinNo': this.data.douyinUserNo, 'userNo': app.globalData.userInfo.userNo, 'douyinUid': e.currentTarget.dataset.douyinuid}),
    })
  },

  //获取视频详情
  getVideoMsg: function(){
    var that = this
    util.request('/douyin/queryDouyinUserInfo',{userNo: app.globalData.userInfo.userNo,douyinUserNo: this.data.douyinUserNo},function(res){
      console.log(res)
      that.setData({
        videoMsg: res
      })
    })
  },

  disMove: function (e) {

  },

  //点赞
  like: function (e) {
    let videoMsg = this.data.videoMsg

    if (videoMsg.isClickGood == '0') {
      videoMsg.isClickGood = '1'
      videoMsg.charmCount += 1
    } else if (videoMsg.isClickGood == '1') {
      videoMsg.isClickGood = '0'
      videoMsg.charmCount -= 1
    }

    this.setData({
      videoMsg: videoMsg,
    })

    
    util.request('/douyin/userClickGood', { userNo: app.globalData.userInfo.userNo, douyinUserNo: videoMsg.douyinUserNo }, function (res) {
      console.log(res)
    })
  },

//返回
back: function(e){
  wx.navigateBack({
    //
  })
},

  //复制联系方式
  copy: function (e) {
    let data = e.currentTarget.dataset.contact
    wx.setClipboardData({
      data: data,
      success: function (res) {
        wx.showToast({
          title: '复制成功',
          icon: 'none',
        })
      }
    })
  },
})
